<?php
/**
 * 矿机套餐model
 */
namespace app\common\model;

use think\Model;

class MiningSpecification extends Model
{
    protected $name = 'mining_specification';

    /**
     * 查询所有矿机套餐
     * @param array $where  查询条件
     * @param string $filed 指定字段
     * @param string $order 排序
     * @return MiningSpecification[]|array|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getListAll($where = [],$filed = '',$order = 'id desc'){
        $data = self::where($where);
        return $data->order($order)->select();
    }

    /**
     * 查询矿机套餐详情
     * @param $id
     * @return MiningSpecification|array|mixed|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getDetails($id,$field = ''){
        $data = self::where('id',$id);
        if(!empty($field))$data = $data->field($field);
        return $data->find();
    }

}